<template>
<div>
  <ClassInfo @changeXkkh="changeXkkh" @hasClass="hasClass" userIdentity="Student" label="提交" @handchange="save" barButton="!disable"></ClassInfo>
  
  </div>
</template>
<script>
import ClassInfo from '@/components/class_info'
export default {
  data () {
    return {
      timeLong:0,
      
      disable:true,
      noClass:true,
      toast:false,
      SKSC:45,
      nrbm:'',
      ktxq:{},
      saveType:'save',
      allParameters:{},
      sknrList:[],
      sknrIndex:-1
    }
  },components:{
    ClassInfo
  },mounted(){
    let that=this
    let time = setInterval(()=>{
      let kqsj=that.ktxq["SJ"].replace(/-/g,'/')
      //点名时间计算开始
      let classStart = new Date(kqsj+" "+that.allParameters[that.ktxq["DJJ"]+"_class_start"]).getTime()
      let classEnd = new Date(kqsj+" "+that.allParameters[(parseInt(that.ktxq["DJJ"])+parseInt(that.ktxq["SKCD"])-1)+"_class_end"]).getTime()
      let beforeTime = parseInt(that.allParameters["roll_call_before_start"])*60000
      let afterTime = parseInt(that.allParameters["roll_call_after_end"])*60000
      classStart -=beforeTime
      classEnd +=afterTime
      //点名时间计算完成
      //课堂日志截止时间
      let commissary_log_end = new Date(kqsj+" "+that.allParameters["commissary_log_end"]).getTime()
      //学生评教截止时间
      let student_evaluate_end = new Date(kqsj+" "+that.allParameters["student_evaluate_end"]).getTime()
      //教师评学截至时间
      let teacher_evaluate_end = new Date(kqsj+" "+that.allParameters["teacher_evaluate_end"]).getTime()
      let teacher_evaluate_open = that.allParameters["teacher_evaluate_open"]
      let student_evaluate_open = that.allParameters["student_evaluate_open"]
      let nT = new Date()
      let timeNow = nT.getTime()
      if(timeNow>classStart && timeNow<commissary_log_end){
        that.disable=false
      }else{
        that.disable=true
      }
      //console.info(endTime);
    },1000)
  },
  methods: {
    prev(){
      let that=this
      if(that.sknrIndex>=0){
        that.sknrIndex=that.sknrIndex-1
      }
    },
    next(){
      let that=this
      console.info(that.sknrList.length)
      console.info(that.sknrIndex)
      if(that.sknrIndex<that.sknrList.length-1){
        that.sknrIndex=that.sknrIndex+1
      }
    },
    handleToggle (key) {//为什么switch不用调这个方法，因为不需要实时提交数据，区别于点名
      if(!this.disable){
        this[key] = !this[key]
      }
    },
    hasClass(val){
      this.noClass = !val
    },
    changeXkkh(ktxq,allParameters){
      const that = this
      that.sknrIndex = -1
      that.nrbm=ktxq.NRBM
      that.allParameters = allParameters
      that.ktxq = ktxq
     
    }
  }
 
}
</script>
<style>
  .mu-sub-header{
    font-size:20px;
    background-color:whitesmoke;
  }
  .topSelectBtn{
    background-color: blue;
    color:white;
  }
  .mu-list-item-zzg{
    padding:20px;
  }
  
.mt8 {
  margin-top: 8px;
}
.flex-demo {
  text-align: center;
}
.flex-title{
  text-size:18px;
  background-color: #eee;
  padding:10px;
}
.flex-body{
  padding: 10px;
  background-color: #fff;
}
</style>